package cn.livingCloud.dto;

import cn.livingCloud.entity.content.ReplyRule;
import cn.livingCloud.wechat.protocol.MsgType;
import org.apache.commons.lang.StringUtils;

/**
 * Created by DingJie  on 2015/12/9.
 */
public class ReplyRuleFormDto {

    private String uuid;
    //关键字
    private String keyWord;
    //消息类型
    private MsgType msgType = MsgType.text;
    //true:启用,false:禁用
    private boolean enable;

    public ReplyRuleFormDto() {
    }

    public ReplyRuleFormDto(ReplyRule replyRule) {
        this.uuid = replyRule.getUuid();
        this.keyWord = replyRule.getKeyWord();
        this.msgType = replyRule.getMsgType();
        this.enable = replyRule.isEnable();
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public MsgType getMsgType() {
        return msgType;
    }

    public void setMsgType(MsgType msgType) {
        this.msgType = msgType;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public MsgType[] getAllMsgType() {
        return MsgType.values();
    }


    public void updateRule(ReplyRule replyRule) {
        replyRule.setKeyWord(this.keyWord);
        if (StringUtils.isEmpty(uuid)) {
            replyRule.setMsgType(this.msgType);
        }
    }
}
